package com.lgx.mall.basic.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.lgx.common.entity.IdGenerator;
import com.lgx.right.entity.User;

/**
 * 返利设置
 * @author pengdeyi
 *
 */
@Entity
@Table(name="TM_REBATERULE")
public class RebateRule implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public static final String FLLX_LEVEL_MERCHANT = "01";//联盟商家返利
	
	public static final String FLLX_LEVEL_ORGANIZATION_TGZ = "02";//推广站返利 
	
	public static final String FLLX_LEVEL_ORGANIZATION_TGSTATION = "03";//推广中心返利
	
	public static final String FLLX_LEVEL_ORGANIZATION_TGCENTER = "04";//运营中心返利user
	
	public static final String USE_STATION_UNUSE = "1";//使用状态--未使用
	
	public static final String USE_STATION_USE = "0";//使用状态--已使用
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.REBATERULE_ID_GENERATOR)
	@TableGenerator(
			name = IdGenerator.REBATERULE_ID_GENERATOR,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.REBATERULE_ID_GENERATOR,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	private String type;//返利类型
	
	private double rate;//返利利率
	
	private String level;//返利级别
	
	@ManyToOne
	@JoinColumn(name="creater_id")
	private User creater;//返利创建人
	
	private Date createDate;//返利创建时间
	
	private String remarks;//备注
	
	private String isdelete;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public double getRate() {
		return rate;
	}

	public void setRate(double rate) {
		this.rate = rate;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public User getCreater() {
		return creater;
	}

	public void setCreater(User creater) {
		this.creater = creater;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getIsdelete() {
		return isdelete;
	}

	public void setIsdelete(String isdelete) {
		this.isdelete = isdelete;
	}

	public static String changeStaticType(String _type){
		if(_type.equals(FLLX_LEVEL_MERCHANT)){
			return "联盟商家返利";
		}
		if(_type.equals(FLLX_LEVEL_ORGANIZATION_TGCENTER)){
			return "运营中心返利";
		}
		if(_type.equals(FLLX_LEVEL_ORGANIZATION_TGSTATION)){
			return "推广中心返利";
		}
		if(_type.equals(FLLX_LEVEL_ORGANIZATION_TGZ)){
			return "推广站返利";
		}
		
		if(_type.equals(USE_STATION_UNUSE)){
			return "未使用";
		}
		
		if(_type.equals(USE_STATION_USE)){
			return "已使用";
		}
		
		return null;
	}
}
